#pragma once

#include "AngelMemoryManager.h"

class AngelHeapAlloc
{
private:
	U32 m_n_RefCount;

protected:
	AngelHeapAlloc(void);
	virtual ~AngelHeapAlloc();

public:
	//void* operator new(size_t _size)
	//{
	//	//return malloc(_size);
	//	return g_AngelMemoryManagerInstance->Allocate((U32)_size);
	//}
	//void* operator new[](size_t _size) // size of the entire array allocation
	//{
	//	return malloc(_size);
	//}
	//void operator delete(void* _mem, size_t _size)
	//{
	//	//free(_mem);
	//	g_AngelMemoryManagerInstance->Free(_mem, (U32)_size);
	//}
	//void operator delete[](void* _mem/*, size_t _size*/) // only size of one object
	//{
	//	free(_mem);
	//}

	FORCEINLINE void AddRef() { ++m_n_RefCount; }
	FORCEINLINE bool Release() 
	{ 
		if (--m_n_RefCount == 0) 
		{
			delete this;
			return true;
		}
		return false;
	}
};
